<% if @deploy&.persisted? %>
  <% if @deploy.kubernetes? %>
    <div class="tab-pane" id="manifests">
      <% if release = @deploy.kubernetes_release %>
        <% release.release_docs.sort_by { |rd| DeployGroup.with_deleted{ rd.deploy_group&.name_sortable }}.each do |release_doc| %>
          <div>
            <h3><%= release_doc.deploy_group.name %> - <%= link_to release_doc.kubernetes_role.name, [@deploy.project, release_doc.kubernetes_role] %></h3>
            <pre><%= release_doc.resource_template.map(&:deep_stringify_keys).map(&:to_yaml).join("\n") %></pre>
          </div>
        <% end %>
      <% else %>
        Manifests not yet created, reload the page.
      <% end %>
    </div>
  <% end %>
<% elsif @stage&.kubernetes? %>
  <div class="tab-pane" id="manifests">
    <!-- using an iframe to lazy-load the manifest preview as it can be slow -->
    <pre><iframe frameborder="0" seamless src="<%= manifest_preview_project_kubernetes_stage_url(@stage.project, @stage, format: :yaml, git_ref: @deploy.reference) %>" width="100%" height="400"></iframe></pre>
  </div>
<% end %>
